package library.service.impl;

import javax.annotation.Resource;

import library.config.MyBatisUtil;
import library.mapper.BorrowMapper;
import library.po.Borrow;
import library.service.BorrowService;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class BorrowServiceImpl implements BorrowService{

    @Resource
    private BorrowMapper borrowMapper;
    private SqlSession sqlSession;
    public BorrowServiceImpl(){
        sqlSession = MyBatisUtil.getSqlSession();
        borrowMapper = sqlSession.getMapper(BorrowMapper.class);
    }

    public SqlSession getSqlSession() {
        return sqlSession;
    }

    @Override
    public int deleteByPrimaryKey(Integer borrowId) {
        return borrowMapper.deleteByPrimaryKey(borrowId);
    }

    @Override
    public int insert(Borrow record) {
        return borrowMapper.insert(record);
    }

    @Override
    public Borrow selectByPrimaryKey(Integer borrowId) {
        return borrowMapper.selectByPrimaryKey(borrowId);
    }

    @Override
    public int updateByPrimaryKey(Borrow record) {
        return borrowMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<Borrow> selectByUserId(String userId) {
        return borrowMapper.selectByUserId(userId);
    }

    @Override
    public int renew(Integer borrowId) {
        return borrowMapper.renew(borrowId);
    }

    @Override
    public List<Borrow> selectBorrow(String str) {
        return borrowMapper.selectBorrow(str);
    }

    @Override
    public List<Borrow> selectAllBorrow() {
        return borrowMapper.selectAllBorrow();
    }

    @Override
    public int returnBook(Borrow record) {
        return borrowMapper.returnBook(record);
    }


}
